home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 June
/
EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso
/
earcd
/
texts
/
rdhtml2g.lha
/
RDHTML2AG
next >
Wrap
Text File
|
1996-04-16
|
6KB
|
214 lines
/*
RexxDoesHTML2AmigaGuide V0.9, 14 Apr 1996 by Michael Ranner
RexxDoesHTML2AmigaGuide V1.0, 15 Apr 1996 by Michael Ranner
RexxDoesHTML2AmigaGuide V1.1, 16 Apr 1996 by Michael Ranner
This piece of code is Public Domain. Use it, distribute it, modify it!
*/
arg src opt
if index(opt, '?') ~= 0 then do
say 'Source/A'
exit
end
open('HTML', src, 'R')
name = left(src, lastpos('.', src)) || 'guide'
open('Guide', name,'W')
writeln('Guide', '@DATABASE ' || src)
writeln('Guide', '@REMARK Converted by RexxDoesHTML2AmigaGuide V1.1 by Michael Ranner')
writeln('Guide', '@NODE Main')
writeln('Guide', '@WORDWRAP')
spaces = 0
pushes = 0
preformat = 0
listing = 0
do until eof('HTML') = 1
do until (srcline ~= '') | (eof('HTML') = 1)
srcline = readln('HTML')
end
line = ''
if index(srcline, '&') ~= 0 & listing = 0 then
do while srcline ~= ''
parse var srcline start'&'token';'srcline
token = upper(token)
select
when token = 'AMP' then line = line || start || '&'
when token = 'GT' then line = line || start || '>'
when token = 'LT' then line = line || start || '<'
when token = 'QUOT' then line = line || start || '"'
otherwise line = line || start || '&' || token
end
end
else line = srcline
dstline = ''
do while line ~= ''
parse var line start '<'token arg'>' line
token = compress(upper(token))
select
when token = '/XMP' or token = '/LISTING' then do
preformat = preformat - 1
listing = 0
end
when listing = 1 then do
dstline = srcline
leave
end
when token = '/TITLE' then nop
when token = 'I' then dstline = dstline || start || '@{I}'
when token = '/I' then dstline = dstline || start || '@{UI}'
when token = 'B' then dstline = dstline || start || '@{B}'
when token = '/B' then dstline = dstline || start || '@{UB}'
when token = 'H1' | token = 'H2' then dstline = dstline || start || '0A0A'X
when token = '/H1' | token = '/H2' then dstline = dstline || start || '0A0A'X
when token = 'H3' | token = 'H5' then dstline = dstline || start || '0A'X || '@{I}'
when token = '/H3' | token = '/H5' then dstline = dstline || start || '@{UI}' || '0A'X
when token = 'H4' | token = 'H6' then dstline = dstline || start || '0A'X
when token = '/H4' | token = '/H6' then dstline = dstline || start || '0A'X
when token = 'BR' then dstline = dstline || start || '0A'X
when token = 'P' then dstline = dstline || start || '0A0A'X
when token = 'HR' then dstline = dstline || start || '0A'X || '@{U}' || copies(' ', 75) || '@{UU}' || '0A0A'X
when token = 'UL' then do
spaces = spaces + 4
dstline = dstline || start || '0A'X || '@{LINDENT ' || spaces || '}' || '0A'X
end
when token = '/UL' then do
spaces = spaces - 4
dstline = dstline || start || '0A'X || '@{LINDENT ' || spaces || '}' || '0A'X
end
when token = 'OL' then do
spaces = spaces + 4
dstline = dstline || start || '0A'X || '@{LINDENT ' || spaces || '}' || '0A'X
end
when token = '/OL' then do
spaces = spaces - 4
dstline = dstline || start || '0A'X || '@{LINDENT ' || spaces || '}' || '0A'X
end
when token = 'LI' then dstline = dstline || start || '0A'X || '* '
when token = 'A' then do
parse var arg token '=' node
token = compress(upper(token))
node = compress(node, '"')
if (token = 'HREF') & (node ~='') then do
prot = upper(left(node, pos(':', node)))
select
when prot = 'HTTP:' then do
node = pushNode(node)
end
when prot = 'GOPHER:' then do
node = pushNode(node)
end
when prot = 'FTP:' then do
node = pushNode(node)
end
when prot = 'WAIS:' then do
node = pushNode(node)
end
when prot = 'NEWS:' then do
node = pushNode(node)
end
when prot = 'MAILTO:' then do
node = pushNode(node)
end
when prot = 'LOCALHOST:' then do
node = left(node, lastpos('.', node)) || 'guide/MAIN'
node = delstr(node, 1, lastpos('://', node) + 2)
end
otherwise node = left(node, lastpos('.', node)) || 'guide/MAIN'
end
dstline = dstline || start || '@{"'
end
end
when token = '/A' then dstline = dstline || start || '" LINK ' || node || '}'
when token = 'IMG' then do
parse var arg token '=' name token2 '=' alttext
alttext = compress(alttext, '"')
name = compress(name, '"')
if alttext ~= '' then dstline = dstline || start || '@{"[' || alttext || ']" LINK ' || name || '/MAIN}'
else dstline = dstline || start || '@{"[Image]" LINK ' || name || '/MAIN}'
end
when token = 'PRE' then preformat = preformat + 1
when token = '/PRE' then preformat = preformat - 1
when token = 'XMP' | token = 'LISTING' then do
preformat = preformat + 1
listing = 1
end
when token = 'ADDRESS' | token = 'CITE' | token = 'EM' | token = 'VAR' then dstline = dstline || start || '@{I}'
when token = '/ADDRESS' | token = '/CITE' | token = '/EM' | token = '/VAR' then dstline = dstline || start || '@{UI}'
when token = 'STRONG' then dstline = dstline || start || '@{B}'
when token = '/STRONG' then dstline = dstline || start || '@{UB}'
when token = 'BLOCKQUOTE' then dstline = dstline || start || '0A0A'X || '@{I}'
when token = 'BLOCKQUOTE' then dstline = dstline || start || '@{UI}' || '0A0A'X
otherwise dstline = dstline || start
end
end
if preformat = 1 then writeln('Guide', dstline)
else writech('Guide', dstline)
end
writeln('Guide', '0A0A'X || 'Converted at ' || date() || ' with RexxDoesHTML2AmigaGuide by Michael Ranner.' || '0A0A'X)
writeln('Guide', '@ENDNODE')
do while pushes ~= 0
parse pull node
writeln('Guide', '@NODE ' || translate(node, '__', ':/') || '0A0A'X || node || '0A0A'X || @ENDNODE)
pushes = pushes - 1
end
close('Guide')
close('HTML')
exit
pushNode: procedure expose pushes
parse arg node
push node
pushes = pushes + 1
node = translate(node, '__', ':/')
return node